package com.sky.lightleafpicturepavilionserver.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 用户签到记录表
 * @TableName user_sign_record
 */
@TableName(value ="user_sign_record")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class UserSignRecord implements Serializable {
    /**
     * 签到记录ID，主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 用户ID
     */
    @TableField(value = "user_id")
    private Long userId;

    /**
     * 签到日期
     */
    @TableField(value = "sign_date")
    private LocalDate signDate;

    /**
     * 签到获得的能量
     */
    @TableField(value = "energy_reward")
    private Integer energyReward;

    /**
     * 连续签到天数
     */
    @TableField(value = "continuous_days")
    private Integer continuousDays;

    /**
     * 签到时间
     */
    @TableField(value = "create_time")
    private LocalDateTime createTime;

    @Serial
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        UserSignRecord other = (UserSignRecord) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
            && (this.getSignDate() == null ? other.getSignDate() == null : this.getSignDate().equals(other.getSignDate()))
            && (this.getEnergyReward() == null ? other.getEnergyReward() == null : this.getEnergyReward().equals(other.getEnergyReward()))
            && (this.getContinuousDays() == null ? other.getContinuousDays() == null : this.getContinuousDays().equals(other.getContinuousDays()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
        result = prime * result + ((getSignDate() == null) ? 0 : getSignDate().hashCode());
        result = prime * result + ((getEnergyReward() == null) ? 0 : getEnergyReward().hashCode());
        result = prime * result + ((getContinuousDays() == null) ? 0 : getContinuousDays().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        return getClass().getSimpleName() +
                " [" +
                "Hash = " + hashCode() +
                ", id=" + id +
                ", userId=" + userId +
                ", signDate=" + signDate +
                ", energyReward=" + energyReward +
                ", continuousDays=" + continuousDays +
                ", createTime=" + createTime +
                ", serialVersionUID=" + serialVersionUID +
                "]";
    }
}